﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

using WeChatDemo.Models;
using WeChatDemo.Models.DTO;
using WeChatDemo.Utils;
using AutoMapper;
using AutoMapper.Data;

namespace WeChatDemo.DataProvider
{
    public class DAOArticle : DAOBase
    {
        private static string tableName = "Article";

        public static IEnumerable<DTOArticle> GetAllList()
        {
            IEnumerable<DTOArticle> _list = ReaderToList<DTOArticle>("ORDER BY ShowIndex", "v_ArticleDetails");

            return _list;
        }

        public static IEnumerable<DTOArticle> GetList(string queryExpression)
        {
            IEnumerable<DTOArticle> _list = ReaderToList<DTOArticle>(queryExpression, "v_ArticleDetails");

            return _list;
        }

       
        public bool Update(Article model)
        {
            bool flag = false;
            string _sqlString;

            _sqlString = $"UPDATE Article SET Title = {model.Title} WHERE ArticleID = '{model.ArticleID}'";

            SqlHelper.ExecuteNonQuery(_connectionString, CommandType.Text, _sqlString);

            return flag;
        }
    }
}